
	** Clean Wave 3
	
		** Household info
		
		** Roster
		
			use "$dir/rawdata/GSPS Ghana/Wave 3/01b2_roster.dta", clear
		
			gen w3_female=gender==5 if !missing(gender)
			gen w3_age=ageyears
			gen w3_married=maritalstatus==1 if !missing(maritalstatus)
			gen w3_inhh=1
			
			bys FPrimary: gen w3_hh_size=_N
			
			keep FPrimary hhmid w3_* index
			
			tempfile roster
			save `roster', replace
		
		** Depression
		
			/*use "$dir/rawdata/GSPS Ghana/Wave 3/10ai_depression.dta", clear
		
			duplicates report FPrimary interviewedid
			duplicates drop FPrimary interviewedid, force
			
			replace sonervous=1 if nervous==1
			replace sorestless=1 if restless==1
			
			egen w3_depression_score=rowtotal(tired nervous sonervous hopeless restless sorestless depressed everythingeffort nothingcheerup worthless), mi
			egen w3_depression_nonmiss=rownonmiss(tired nervous sonervous hopeless restless sorestless depressed everythingeffort nothingcheerup worthless)
			replace w3_depression_score=. if w3_depression_nonmiss<10 // FIXME: Check if this is the right way
			
			gen w3_depressed=w3_depression_score>=25 if !missing(w3_depression_score) // moderate or severe
			*gen w3_depressed=w3_depression_score>=30 if !missing(w3_depression_score) // severe
			
			ren interviewedid hhmid
			
			keep FPrimary hhmid w3_*
			
			ren w3_* w3_*_original
			
			tempfile depression_original
			save `depression_original', replace*/
			
		** Depression: Updated dataset
		
			use "$dir/rawdata/GSPS Ghana/Updated/roster_kessler_merge.dta", clear
			
			replace sonervous=1 if nervous==1
			replace sorestless=1 if restless==1
			
			egen w3_depression_score=rowtotal(tired nervous sonervous hopeless restless sorestless depressed everythingeffort nothingcheerup worthless), mi
			egen w3_depression_nonmiss=rownonmiss(tired nervous sonervous hopeless restless sorestless depressed everythingeffort nothingcheerup worthless)
			replace w3_depression_score=. if w3_depression_nonmiss<10 // FIXME: Check if this is the right way
			
			gen w3_depressed=w3_depression_score>=25 if !missing(w3_depression_score) // moderate or severe
			*gen w3_depressed=w3_depression_score>=30 if !missing(w3_depression_score) // severe
			
			*ren interviewedid hhmid
			
			keep FPrimary hhmid w3_*
			
			tempfile depression
			save `depression', replace
			
			
		** Ever covered by health insurance
		
			use "$dir/rawdata/GSPS Ghana/Wave 3/06a_insurance.dta", clear
			
			gen w3_healthinsurance_ever=everinsured==1 if !missing(everinsured)
			keep FPrimary hhmid w3_healthinsurance_ever
			tostring FPrimary, replace
			
			tempfile healthinsurance
			save `healthinsurance', replace
		
		** Illness or injury over the past 2 weeks
		
			use "$dir/rawdata/GSPS Ghana/Wave 3/06f_past2weeks.dta", clear
			
			gen w3_ill_inj=(anyillness==1 | anyillness==2 | anyillness==3) if !missing(anyillness)
			gen w3_ill_inj_stopactivity=stopactivities==1 if !missing(stopactivities) 
			replace w3_ill_inj_stopactivity=0 if w3_ill_inj==0
				
			keep FPrimary hhmid w3_*
			tostring FPrimary, replace
			tempfile illnessinjury
			save `illnessinjury', replace
		
		** Merge and save
		
			use `roster', clear
			*merge 1:1 FPrimary hhmid using `employment1', gen(merge_employment1)
			*merge 1:1 FPrimary hhmid using `employment2', gen(merge_employment2)
			*merge 1:1 FPrimary hhmid using `enterprise', gen(merge_enterprise)
			merge 1:1 FPrimary hhmid using `depression', gen(merge_depression)
			*merge 1:1 FPrimary hhmid using `depression_original', gen(merge_depression_original)
			merge 1:1 FPrimary hhmid using `healthinsurance', gen(merge_healthinsurance)
			merge 1:1 FPrimary hhmid using `illnessinjury', gen(merge_illinj)
			*merge m:1 FPrimary using `urban', gen(merge_urban)
			
			tab1 merge*
			drop if merge_depression==2
			
			ren FPrimary hhid
			ren hhmid indiv
			
			order hhid indiv w3_*
			keep hhid indiv w3_*
			
			destring hhid, replace
			
			save "$dir/data/gha_w3_individual.dta", replace
	
	** Source for Kessler depression stuff

		* https://www.worksafe.qld.gov.au/__data/assets/pdf_file/0010/22240/kessler-psychological-distress-scale-k101.pdf
